package net.stratusprogramming.school.Game.Framework.Items;

import net.stratusprogramming.school.Game.Framework.Battle.Combatant;
import net.stratusprogramming.school.Game.Framework.System.InstanceMgr;
import net.stratusprogramming.school.Game.Framework.System.Logger;

/**
 * 
 * @author Dominic Vitello, Patrick Lienau, Jeremy Pan
 * 5-3-2012
 * Usable Class
 * extends Item
 * For all items that have an "on use" ability
 *
 */
public abstract class Usable extends Item	{
	
	/**
	 * Number of uses for a Usable item
	 */
	protected static int uses = 0;
	
	/**
	 * Max number of uses for a Usable item
	 */
	protected static int maxUses = 1;
	
	/**
	 * Creates a empty usable
	 */
	public Usable() {
		
	}
	
	/**
	 * Creates a new usable
	 *
	 * @param name name of usable
	 * @param value monetary value of usable
	 * @param weight weight of usable 
	 * @param maxUses max number of uses before destroyed, 0 = infinite
	 */
	public Usable(String name, float value, float weight, int maxUses)	{
		super(name, value, weight);
		this.maxUses = maxUses;		
	}

	
	/**
	 * Increments the use of the item
	 * 
	 * @param user the one to use the item
	 */
	public boolean use(Combatant user) {
		if(maxUses == 0) return false;
		else if(maxUses < uses) return false;
		else {
			uses++;
			if(uses >= maxUses) {
				user.getItems().remove(this);
			}
			return true;
		}
				
	}
}
